<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>内存知识</h2>
    <ul>
        <li>栈内存（tack）：存放变量的名字。</li>
        <li>堆内存（heap）：存放变量的本体（数据）</li>
    </ul>
    <script>
        // new：表示在堆内存中开辟一个空间。
        // let a：表示在栈内存中存放一个变量名（指针）
        // =：表示将变量指向给指针
        let a = new Object();
       

        let i = 100;

        function changeDate1(i) {
            i = 200;
            console.log("方法内i = ",i);
        }

        console.log("方法外，调用前i = ",i);
        changeDate1(i);
        console.log("方法外，调用后i = ",i);

        function changeObject(a) {
            a.name = "罗佰君";
            console.log("方法内a.name = ",a.name);
        }


        a.name = "奉先";
        console.log("方法外，调用前a.name = ",a.name);
        changeObject(a);
        console.log("方法外，调用后a.name = ",a.name);

        let c = {}; // new Object()
        let d = {}; // new Object()
        console.log(c == d); // false
        // 引用数据类型比较相等，比较的是不是同一个内存地址。

        let e = c;
        console.log(c == e); // true
        
        e.name = "奉先";
        console.log(c.name); 


    </script>
</body>
</html>